<?php

include_once __DIR__ . '/BaseShell.php';
$litigantName = '张三';

$res = Module_Mediate_ReturnedMoneyPlanDetail::getInstance()->getAllBySearch(['caseId'],['where'=>["litigantName = '{$litigantName}'","planId = '28'"]]);

var_dump($res);
die;
$res = Module_Mediate_CaseLitigant::getInstance()->getAllBySearch(['caseId'],['where'=>["litigantName like '%{$litigantName}%'"]]);
die;
use Lib_BaseTraits;

class AccountLog extends Model_BaseModel
{
    private $table = "account_log";

    function __construct($month = '')
    {
        if ($month) {
            $this->table = $this->table . '_' . $month;
        }
        // 选择连接的数据库
        parent::_init('mediation');
    }
    function test()
    {
        $case_id = 1;
        $litigant = [
            [
                'caseId'=>1,
                'litigantName'=>1,
                'cardId'=>1,
                'telephone'=>1,
                'type'=>1,
            ],
            [
                'caseId'=>1,
                'litigantName'=>1,
                'cardId'=>1,
                'telephone'=>1,
                'type'=>1,
            ]
        ];
        $sql = "INSERT INTO case_litigant
		(`caseId`,`litigantName`,`cardId`,`telephone`,`type`)
		VALUES ";
        $str = '';
        $saveData = [];
        foreach ($litigant as $i => $val) {
            $str .= ',(' . ':caseId' . $i . ',' . ':litigantName' . $i . ',' . ':cardId' . $i . ',' . ':telephone' . $i . ',' . ':type' . $i . ')';
            $saveData[':caseId' . $i] = $case_id;
            //$saveData[':defendant_name'.$i] = Lib_infoAes::getInstance()->aesEncrypt($val['defendant_name']);
            $saveData[':litigantName' . $i] = ($val['litigantName']);
            $saveData[':type' . $i] = empty($val['type']) ? 2 : 1;
            $saveData[':cardId' . $i] = $val['cardId'];
            $saveData[':telephone' . $i] = $val['telephone'];
        }

        $sql = $sql . trim($str, ',');
        return $this->dao->conn(false)->noCache()->preparedSql($sql, $saveData)->affectedCount();
    }
}
$model = new AccountLog();
$res = $model ->test();die;



Module_InfoBase_MediationOrgan::getInstance()->getAllBySearch(
    ['id','name'],
    ["where" => []],
    true
);die;
$res = $res = Module_CallCenter_YunKeFu_Call::getInstance(2)->queryUserState(
    [
        'workerId'=>8000,
    ]
);
var_dump($res);

$res = $res = Module_CallCenter_YunKeFu_Call::getInstance(1)->queryUserState(
    [
        'workerId'=>6000,
    ]
);
var_dump($res);die;

$res = Lib_FlashSMS_Main::sendSMS('17310698030');

//$repairData = Module_Repair_RepairResult::getInstance()->getItemById(20,true);
//$repairData['seatNumber'] ='02381911320';
//$repairData['showNumber'] ='02381911320';
//$res = Lib_Repair_Main::bindTel([
//    'pass'=> $repairData['repairType'] == 1 ? "YiDong" : "LianTong",
//    'data'=>$repairData
//]);
//var_dump($res);die;
//$param['mobileId'] = 18;
//$param['mobileType'] = 2;
//$param['workerId'] = 8000;

//if(in_array($param['mobileType'],[2,3])){
//    $repairData = Module_Repair_RepairResult::getInstance()->getItemById($param['mobileId'],true);
//    $repairData['seatNumber'] = '075726952284';
//    $repairData['showNumber'] = '075726952284';
//    $res = Lib_Repair_Main::bindTel([
//        'pass'=> $repairData['repairType'] == 1 ? "YiDong" : "LianTong",
//        'data'=>$repairData
//    ]);
//
//    $param['toTel'] = $res['data']['toTel'];
//    Lib_Redis_String::setex($param['workerId']."_fl",1800,$param['toTel']);
//    var_dump($res);die;
//
//}
//die;
//挂断解绑
//$mobile = Lib_Redis_String::get($param['workerId']."_fl");
//if($mobile){
//    $res = Lib_Repair_Main::unBindTel([
//        'telX'=>$mobile
//    ]);
//    var_dump($res);die;
//}
//
//
//
//$res = zipFolder(LIBRARY_DIR.'/../evidencefiles/files/exportFilesRecord/'."3录音文件", LIBRARY_DIR.'/../evidencefiles/files/exportFilesRecord/'."3录音文件.zip");
//function zipFolder($source, $destination) {
//    if (!extension_loaded('zip') || !file_exists($source)) {
//        return false;
//    }
//
//    $zip = new ZipArchive();
//    if (!$zip->open($destination, ZipArchive::CREATE)) {
//        return false;
//    }
//
//    $source = str_replace('\\', '/', realpath($source));
//
//    if (is_dir($source) === true) {
//        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
//
//        foreach ($files as $file) {
//            $file = str_replace('\\', '/', $file);
//
//            // Ignore "." and ".." folders
//            if (in_array(substr($file, strrpos($file, '/')+1), array('.', '..')))
//                continue;
//
//            $file = realpath($file);
//
//            if (is_dir($file) === true) {
//                $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
//            } else if (is_file($file) === true) {
//                $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
//            }
//        }
//    } else if (is_file($source) === true) {
//        $zip->addFromString(basename($source), file_get_contents($source));
//    }
//
//    return $zip->close();
//}
//
//echo  hash("sha256", 17310698030);die;
//$param['workerId'] = 8001;
//$outNumber = Lib_Redis_Hash::hGet('WORK_OUT_NUM',$param['workerId']);
//if($outNumber){
//    $param['OutShow'] = $outNumber;
//    var_dump($outNumber);
//
//    echo "有";
//}else{
//    $worker = Module_Mediate_Workernumber::getInstance()->getOne([],["workerId={$param['workerId']}","isDel=1"]);
//    if(empty($worker['outNumber'])){
//        echo 111;
//    }
//    $param['OutShow'] = $worker['outNumber'];
//    Lib_Redis_Hash::hset('WORK_OUT_NUM',$param['workerId'],$worker['outNumber']);
//    echo "无";
//    var_dump($worker['outNumber']);
//
//}
//die;
//$res = Module_CallCenter_YunKeFu_Call::getInstance()->getCCAgentsByAcc();
//$res = Module_CallCenter_YunKeFu_Call::getInstance()->queryQueue();
//
$res = Module_CallCenter_YunKeFu_Call::getInstance()->callOut(
    [
        'workerId'=>'8001',
        'toTel'=>'17310698030',
        'OutShow'=>'02389354189'
    ]
);

//$res = Module_CallCenter_YunKeFu_Call::getInstance()->setIdle(
//    [
//        'workerId'=>'8011',
//    ]
//);
//$res = Module_CallCenter_YunKeFu_Call::getInstance()->setBuys(
//    [
//        'workerId'=>'8011',
//    ]
//);
//$res = Module_CallCenter_YunKeFu_Call::getInstance()->queryUserState(
//    [
//        'workerId'=>'8003',
//    ]
//);

var_dump($res);die;







die;
$res = Module_CallCenter_YunKeFu_Call::getInstance()->queryUserState(['exten'=>8289]);
//$res = Module_CallCenter_YunKeFu_Call::getInstance()->getCCAgentsByAcc(['Exten'=>8294]);
var_dump($res);die;
var_dump(Lib_Repair_Base_YD::generateAuthorization());die;
$appid = 'BJyinxun_211102';
$key = 'edcd6c5ffb2a068fcb1008aaea9b01e1';
$time = 1712826781256;
$ekey = substr(md5($key),3,16);
Lib_Repair_Base_Tool::encrypt($appid.$time,$ekey);die;


$result = Lib_Repair_Implement_LianTong::getInstance()->unbinding([
    'telX'=>'13198470485',
]);
var_dump($result);die();
$result = Lib_Repair_Implement_LianTong::getInstance()->binding([
    'batchNo'=>'65a51739e1fb3524ed088bfe',
    'idCard'=>'84eba2b17785087c779973d44b7b88309dc0f2328e9c78eca5426bda144bcec1',
    'unicomCustomerId'=>'Z05sTaIS',
    'seatNumber'=>'02863210125',
    'showNumber'=>'02863210125'
]);//
var_dump($result);die;
Module_Task_Repair::submitISPHandler([
    'batchId'=>29,
    'repairType'=>2,
]);die;
var_dump(strtotime('132132'));die;
echo Lib_Function::getInstance()->getM('2024/01/15','2023/05/15');die;
$res = Lib_FlashSMS_Main::sendSMS(18801271672);
var_dump($res);die;


$param['pass'] = "YiChao";
$param['wokerId'] = "8134";
$param['toTel'] = "17310698030";
$param['execute'] = 'callout';
//
//$param['execute'] = 'hangUp';
//$param['wokerId'] = "8134";



$res = call_user_func(array('Module_CallCenter_Main', 'request'), $param);
var_dump($res);die;

//function downloadFile($callId){
//    //初始化文件
//    $save_date = date('Y-m-d').'/';
//    $savePath = LIBRARY_DIR."/../recordfiles/".$save_date;
//    if(!file_exists($savePath)){
//        if(!@mkdir($savePath,0777,true)){
//            Func_Log::write('call_record', "Can not make dir",$savePath);
//            return '';
//        }
//    }
//    //录音已经下载
//    if(file_exists($savePath.$callId.'.mp3')){
//        return $save_date.$callId.'.mp3';
//    }
//    $res = Module_CallCenter_ZhonTou_RecordFile::getInstance()->getFile(['callIds'=>$callId]);
//    $return = json_decode($res,true);
//    if($return && isset($return['status']) && $return['status'] == false){
//        $num = Lib_Redis_String::get("DOWNLOADFILE" . $callId);
//        $num = $num ? $num : 1;
//        if($num > 5){
//            return '';
//        }
//        sleep($num);
//        Lib_Redis_String::setex("DOWNLOADFILE" . $callId,1800,$num+1);
//        return downloadFile($callId);
//    }
//    $fp = fopen($savePath.$callId.'.mp3', 'w');
//    $result = fwrite($fp, $res);
//    fclose($fp);
//    if($result && file_exists($savePath.$callId.'.mp3')){
//        return $save_date.$callId.'.mp3';
//    }
//    Func_Log::write('call_record', "downloadFile fail","callId = ".$callId ."res = ",var_export($result,1));
//    $num = Lib_Redis_String::get("DOWNLOADFILE" . $callId);
//    $num = $num ? $num : 1;
//    sleep(2);
//    if($num > 5){
//        return '';
//    }
//    Lib_Redis_String::setex("DOWNLOADFILE" . $callId,1800,$num+1);
//    return downloadFile($callId);
//}
//var_dump(downloadFile('fc-a966b752c76e35f03b41dead33c870c0'));;